package com.ruoyi.controller;

import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.service.CompetitionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @author kaka.huang
 * @for study
 */
@RestController
public class CompetitionController {
    /*
     * 左侧展示top值为空的数据
     * 数据格式
     * 时间+成员+比赛名+奖项+证书+top*/
    @Autowired
    private CompetitionService competitionService;

    @Anonymous
    @GetMapping("/getOutstandingRecords")
    public Map<String, Object> getOutstandingRecords() {
        HashMap<String, Object> ResData = new HashMap<>();
        try {
            Map<String, Object> result = competitionService.selectLCompetition();
            ResData.put("message","Success");
            ResData.put("code",200);
            ResData.put("data",result);
            return ResData;
        }catch (Exception e) {
            ResData.put("message","Error");
            ResData.put("code",e.toString());

            return ResData;
        }
    }

    /*
     * 右侧展示top值不为空的数据
     * 数据格式
     * 时间+成员+比赛名+奖项+证书+top*/

    @Anonymous
    @GetMapping("/getHomePageGameRecords")
    public Map<String, Object> getHomePageGameRecords() {
        HashMap<String, Object> ResData = new HashMap<>();
        try {
            Map<String, Object> result = competitionService.selectRCompetition();
            ResData.put("message","Success");
            ResData.put("code",200);
            ResData.put("data",result);
            return ResData;
        }catch (Exception e) {
            ResData.put("message","Error");
            ResData.put("code",400);
            return ResData;
        }
    }
}
